package com.lantosec.hmrp.core.util;

import org.apache.commons.codec.binary.Hex;

import java.security.MessageDigest;

public class Md5Utils {

    /***
     * password：密码
     * salt：盐密码
     */
    public static String generate(String password,String salt) {
        password = md5Hex(password + salt);
        return password;
    }

    private static String md5Hex(String src) {
        try {
            MessageDigest md5 = MessageDigest.getInstance("MD5");
            byte[] bs = md5.digest(src.getBytes());
            return new String(new Hex().encode(bs));
        } catch (Exception e) {
            return null;
        }
    }
}
